
#include "Mediator.h"
#include "Colleague.h"

using namespace npMediator;


//other constructors

//public methods
void Mediator::send(const string& msg, int targetId) throw(ErrorEnum)
{
    shared_ptr<Colleague> clg;
    if (this->colleagues.find(targetId) != this->colleagues.end()
    && (clg = this->colleagues[targetId].lock()))
    {
        clg->notify(msg);
    }
    else
    {
        throw ErrorEnum::NoTargetColleague;
    }
}

bool Mediator::addColleague(int colleagueId, weak_ptr<Colleague> colleague) throw()
{
    auto insertPair = this->colleagues.insert(map<int, weak_ptr<Colleague> >::value_type(colleagueId, colleague));
    return insertPair.second;
}

//protected methods

//private methods

//static part

//others
